#ifndef __BHTTP_BCURL_H__
#define __BHTTP_BCURL_H__
#pragma once

#include "bclient.h"
#include <curl/curl.h>

namespace bhttp
{

class bcurl
{
public:
	explicit bcurl();
	~bcurl();

	bool init(const bclient* clt,
		const std::shared_ptr<brequest>& req,
		std::shared_ptr<bresponse>& rep);

	bool mime_init(const std::shared_ptr<brequest>& req);

	bool perform(int* rep_code);

	template<typename T>
	bool option(CURLoption option, T data)
	{
		return CURLE_OK == curl_easy_setopt(curl_, option, data);
	}
private:
	CURL* curl_{ nullptr };
	curl_slist* headers_{ nullptr };
	curl_mime* mime_{ nullptr };
};

}

#endif //__BHTTP_CURL_H__
